<?php
namespace App\Services\Export;

use App\Services\Export\WordAbstract;

class WordNineCheckAgainLog extends WordAbstract
{
    public function set($baseData = [], $tableData = [])
    {
        if(count($baseData)) {
            foreach ($baseData as $k => $v) {
                $this->templateProcessor->setValue($k,$v);
            }
        }
        if(count($tableData)) {
            $this->templateProcessor->cloneRow('num', count($tableData));
            foreach ($tableData as $k => $v) {
                foreach($v as $kk=>$vv) {
                    if($kk!=='dagerPicture'&&$kk!=='reformPicture') {
                        $this->templateProcessor->setValue($kk.'#'.$k, $vv);
                    } else {
                        if(!empty($vv)) {
                            if(is_array($vv)){
                                $path = $vv['path'];
                                $width = isset($vv['width'])?$vv['width']:200;
                                $height = isset($vv['height'])?$vv['height']:150;
                            } else {
                                $path = $vv;
                                $width = 200;
                                $height = 150;
                            }
                            $this->templateProcessor->setImageValue($kk.'#'.$k,  array('path' => $path, 'width' => $width, 'height' => $height));
                        } else {
                            $this->templateProcessor->setValue($kk.'#'.$k, $vv);
                        }
                    }
                }/*处理数据*/
            }/*处理表格数据*/  
        } else {
            $this->templateProcessor->setValue(array('num','category','accords','dagerDescription','reformProposal','dagerPicture','reformStatus','reformPicture','remark'),array('','','','','','','','',''));
        }
        
    }
}